import { Bk_Order } from 'src/order/bk_order.entity';
import { Bk_Product_Info } from 'src/product_info/product_info.entity';
import { Bk_Series } from 'src/series/bk_series.entity';
import { Bk_Subject } from 'src/subject/bk_subject.entity';
import { Entity, Column, PrimaryGeneratedColumn, OneToMany, ManyToOne } from 'typeorm';

@Entity()
export class Bk_Product {
    @PrimaryGeneratedColumn()
    id: number;

    @Column({ unique: true, nullable: false })
    product_name: string;

    @Column({ type: "text", nullable: false })
    product_description: string;

    @Column({ type: "tinyint", nullable: false })
    product_type: number //0 视频 1试卷

    @Column({ type: "decimal", nullable: false })
    product_price: number

    @Column()
    thumbnail_url: string;
    
    @Column()//排序
    order_number: number;

    @ManyToOne(() => Bk_Subject, subject => subject.product)
    subject: Bk_Subject[];

    @ManyToOne(() => Bk_Series, series => series.product)
    series: Bk_Series[];

    @OneToMany(() => Bk_Order, order => order.product)
    order: Bk_Order[];

    @OneToMany(() => Bk_Product_Info, product_info => product_info.product)
    product_info: Bk_Product_Info[];
}